/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2024-12-09
 * Time: 12:06
 */
public class test1 {
    /*
    NewCoder BM19  寻找峰值
    给定一个长度为n的数组nums，请你找到峰值并返回其索引。数组可能包含多个峰值，在这种情况下，返回任何一个所在位置即可。
     */

    public int findPeakElement (int[] nums) {
        // write code here
        int left=0;
        int right = nums.length-1;
        while(left<right){
            int mid = (right-left)/2+left;
            if(nums[mid]>nums[mid+1]){
                right = mid;
            }else{
                left = mid+1;
            }
        }
        return right;
    }
}
